package com.coocaa.ops.admin.v1.panel.biz.impl;

import com.coocaa.ops.admin.v1.panel.biz.ISubPanelBiz;
import com.coocaa.ops.admin.v1.panel.mapper.ISubPanelMapper;
import com.coocaa.ops.common.core.base.BaseBizImpl;
import com.coocaa.ops.common.core.base.enums.ResourceStatusEnums;
import com.coocaa.ops.common.core.base.mybatis.QueryTemplate;
import com.coocaa.ops.common.core.biz.panel.entity.SubPanelInfoEntity;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author bijiahao
 * @description
 * @date 2020/6/16 17:51
 */
@Service
public class SubPanelBizImpl extends BaseBizImpl<ISubPanelMapper, SubPanelInfoEntity> implements ISubPanelBiz {

    @Override
    public void deleteBatch(List<Integer> ids) {
        if(CollectionUtils.isNotEmpty(ids)){
            getMapper().deleteBatchIds(ids);
        }
    }

    @Override
    public void logicDelBatch(List<Integer> subPanelIdList) {
        if(CollectionUtils.isEmpty(subPanelIdList)){
            return;
        }
        QueryTemplate<SubPanelInfoEntity>  queryTemplate = QueryTemplate.getEqQueryTemplate("flag", 1);
        queryTemplate.lambda().in(SubPanelInfoEntity::getId, subPanelIdList);
        SubPanelInfoEntity update = new SubPanelInfoEntity();
        update.setFlag(ResourceStatusEnums.OFF_LINE.getStatus());
        getMapper().update(update, queryTemplate);
    }
}
